package com.maybach.core.dubbo.consumer.adapter;

import com.audi.dubbo.api.search.SearchItemService;
import com.audi.dubbo.api.search.vos.SearchForm;
import com.audi.dubbo.api.search.vos.SearchResult;
import com.audi.dubbo.api.search.vos.SearchResultVo;
import com.maybach.core.dubbo.consumer.annotation.Monitor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by wenhua on 16/2/1.
 */
@Component
@Monitor(serviceName = "searchItemService",desc = "搜索商品服务")
public class SearchItemServiceDubboAdapter {
    private Logger log = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private SearchItemService searchItemService;

    /**
     *
     * @param searchForm
     * @return
     */
    SearchResult<List<SearchResultVo>> baseItemSearch(SearchForm searchForm) {
        SearchResult<List<SearchResultVo>>  result = null;
        try{
            result = searchItemService.baseItemSearch(searchForm);
        } catch (Exception e) {
            log.error("搜索商品服务 SearchItemServiceDubboAdapter args:"+ searchForm.toString(), e);
        }
        return result;
    }

    /**
     *
     * @param searchForm
     * @return
     */
    SearchResult<List<SearchResultVo>> b2bCarSearch(SearchForm searchForm) {
        SearchResult<List<SearchResultVo>>  result = null;
        try{
            result = searchItemService.b2bCarSearch(searchForm);
        } catch (Exception e) {
            log.error("搜索商品服务 SearchItemServiceDubboAdapter args:"+ searchForm.toString(), e);
        }
        return result;
    }

}
